package com.woniuxy.springmvc.exception;

import bean.ResultMsg;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author linke
 * @version 1.0
 * @className: ExceptionHandleRest
 * @description: 不跳转页面的异常处理
 * @date 2021/11/14 22:30
 *
 * 不跳转页面的异常处理
 */
@RestControllerAdvice
public class ExceptionHandleRest {



    @ExceptionHandler
    public ResultMsg hanlder(Exception e){
        ResultMsg msg = new ResultMsg("10000","未知错误");

        if(e instanceof NullPointerException){
            msg.setCode("10001");
            msg.setMsg("系统繁忙，请稍后重试！");
        }
        //继续做异常的判断


        return msg;
    }

}
